package com.hanamaki.databaseTest;

//import com.mysql.cj.jdbc.Driver;

import java.sql.*;

public class JdbcTest {

    public static void main(String[] args) throws ClassNotFoundException, SQLException {

        // 1.加载驱动
        Class.forName("com.mysql.cj.jdbc.Driver");

        //用户信息
        String username = "root";
        String password = "123456";
        String DB_URL = "jdbc:mysql://127.0.0.1:3306/mysources?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC";
        // 3. 连接数据库
        Connection connection = DriverManager.getConnection(DB_URL, username, password);

        Statement statement = connection.createStatement();

        // 编写sql语句
        String sql = "SELECT * from students";
        ResultSet resultSet = statement.executeQuery(sql);


        System.out.println("age");
        while (resultSet.next()) {

            System.out.println(resultSet.getObject("age"));
        }

        resultSet.close();
        statement.close();
        connection.close();

    }



}
